<?php

	include("common.php");
	
	if(!empty($_POST)){
		$dir = uniqid(rand(0, 1000));
		mysql_query("INSERT INTO `197_albums` ( `title`, `description`, `create_date`, `dir_name` ) VALUES ( '" . $_POST['title'] . "', '" . $_POST['description'] . "', '" . date("Y-m-d") . "', '" . $dir . "' )");
		mkdir("../files/" . $dir);
		chmod("../files/" . $dir, 0777);
		include("header.php");
?>
<?php if(!AJAX){ ?><h1>新增相簿</h1><?php } ?>
<p>新增成功<?php if(!AJAX){ ?>，請<a href="albumFind.php">按此</a>返回<?php } ?>。</p>
<?php

		include("sidebar.php");
		include("footer.php");
		
		exit;

	}
	
?>
<?php include("header.php"); ?>
<h1>新增相簿</h1>
<form action="albumAdd.php" id="album-add-form" method="POST">
	<p><label>標題：<input type="text" name="title" id="title" /></label></p>
	<p><label>描述：<input type="text" name="description" id="description" size="50" /></label></p>
	<p><button class="custom" onclick="$('#album-add-form').submit();">新增</button>｜<a href="albumFind.php">返回</a></p>
</form>
<?php include("sidebar.php"); ?>
<?php include("footer.php"); ?>